class Solution {
public:
    bool detectCapitalUse(string word)
    {
        int cnt = 0;
        for (auto& a : word)
            if (a >= 'A' && a <= 'Z') cnt++;

        if (cnt == 0) return true;
        if (cnt == word.size()) return true;
        if (cnt == 1 && word[0] >= 'A' && word[0] <= 'Z') return true;

        return false;
    }
};